package com.kgcx.organization.controller;

import com.kgcx.common.bean.RequestData;
import com.kgcx.common.bean.ReturnData;
import com.kgcx.common.constant.ResultCode;
import com.kgcx.common.controller.BaseController;
import com.kgcx.organization.domain.AirportParking;
import com.kgcx.organization.service.AirportParkingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(description = "机场泊车位泊车位", tags = "泊车位接口")
@RestController
@RequestMapping("airportParking")
public class AirportParkingController extends BaseController {
	@Autowired
	private AirportParkingService airportParkingService;

	@ApiOperation(value = "新增机场泊车位", httpMethod = "POST", notes = "接口")
	@PostMapping("addAirportParking")
	public ReturnData<?> addAirportParking(@RequestBody AirportParking airportParking) {
		airportParkingService.addAirportParking(airportParking);
		return new ReturnData<>();
	}

	@ApiOperation(value = "修改机场泊车位", httpMethod = "POST", notes = "接口")
	@PostMapping("updateAirportParking")
	public ReturnData<?> updateAirportParking(@RequestBody AirportParking airportParking) {
		airportParkingService.updateAirportParking(airportParking);
		return new ReturnData<>();
	}

	@ApiOperation(value = "根据kid查找机场泊车位", httpMethod = "POST", notes = "接口")
	@PostMapping("getAirportParking")
	@ApiImplicitParam(name = "kid", value = "1", required = true, paramType = "query", dataType = "Long", dataTypeClass = Long.class)
	public ReturnData<?> getAirportParking(Long kid) {
		ReturnData<AirportParking> returnData = ReturnData.getResult();
		AirportParking airportParking = airportParkingService.getAirportParking(kid);
		returnData.setData(airportParking);
		returnData.setCode(ResultCode.SUCCESS);
		returnData.setMsg("查询成功");
		return returnData;
	}

	@ApiOperation(value = "分页查询机场泊车位", httpMethod = "POST", notes = "接口")
	@PostMapping("getAirportParkingList")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "pageNum", value = "页码", required = false, paramType = "query", dataType = "int", dataTypeClass = Integer.class),
			@ApiImplicitParam(name = "pageSize", value = "页容量", required = false, paramType = "query", dataType = "int", dataTypeClass = Integer.class),
			@ApiImplicitParam(name = "airportId", value = "机场id", required = false, paramType = "query", dataType = "Long", dataTypeClass = Long.class),
			@ApiImplicitParam(name = "airportTerminalId", value = "航站楼id", required = false, paramType = "query", dataType = "Long", dataTypeClass = Long.class) })
	public ReturnData<?> getAirportParkingList() {
		ReturnData<List<AirportParking>> returnData = ReturnData.getResult();
		RequestData requestData = this.getRequestData();
		List<AirportParking> list = airportParkingService.getAirportParkingList(requestData);
		returnData.setData(list);
		returnData.setCode(ResultCode.SUCCESS);
		returnData.setMsg("查询成功");
		return returnData;
	}
}
